<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">    
/******************************************************************
*Server    :  <xsl:value-of select="//Server"/>
*Database  :  <xsl:value-of select="//Database"/>
*name  :  dbo.UP_<xsl:value-of select="//Meta/Name"/>_Update
*function  :  
*author    :  <xsl:value-of select="//Author"/>
*CreateDate   :  <xsl:value-of select="//CreateDate"/>
*Description  :  
*Reference Version : V1.0
=====================================================================
*change history
----------------------------------------------------------
*V1.0
*Date  : <xsl:value-of select="//CreateDate"/>
*Modify by : <xsl:value-of select="//Author"/>
*Description  : 
********************************************************************/
CREATE PROCEDURE dbo.UP_<xsl:value-of select="//Meta/Name"/>_Update
<xsl:for-each select="//Meta/Columns/Column">
	@<xsl:value-of select="Name"/><xsl:text>&#9;</xsl:text><xsl:value-of select="ColumnType"/><xsl:if test="position()!=last()">,</xsl:if>
</xsl:for-each>
AS

UPDATE <xsl:value-of select="//Meta/Name"/> 
SET 
<xsl:for-each select="//Meta/Columns/Column[IsPrimaryKey!='true']">
  <xsl:value-of select="Name"/>=@<xsl:value-of select="Name"/>
  <xsl:if test="position()!=last()">,&#10;</xsl:if>
</xsl:for-each>
WHERE <xsl:for-each select="//Meta/Columns/Column[IsPrimaryKey='true']">
  <xsl:value-of select="Name"/>=@<xsl:value-of select="Name"/><xsl:if test="position()!=last()"> AND </xsl:if>
</xsl:for-each>
  </xsl:template>

</xsl:stylesheet>
